@echo off
cls

:main
	
	call :ShowHelp
	
	:: if "%1" == "" (
	:: 	SET /P ALBUM_NAME=Input a number X for the album aldanysia[X]:
	:: ) else (
	:: 	set ALBUM_NAME=%1
	:: )
	:: set ALBUM_NAME=aldanysia%ALBUM_NAME%
	
	:: to dump album
	set TDA_UN=%1
	set TDA_PW=%2
	
	:: write to summary album
	set TWSA_UN=%3
	set TWSA_PW=%4
	set TWSA_T=%5
	
	:: write to calendar
	set TWC_UN=%6
	set TWC_PW=%7
	set TWC_T=%8
	set TWC_SALU=%9
	
	set BinPath=%~d0%~p0..\bin
	
	pushd "%~d0%~p0"
	
	set ALBUM_DUMP_FILE=%temp%\%TDA_UN%.albumDump.xml
	
	echo [Extract Album Infomation]
		echo PicasaHelper dumpAlbumXML /a %TDA_UN% /p %TDA_PW% /o %ALBUM_DUMP_FILE% /level photo
		%BinPath%\PicasaHelper dumpAlbumXML /a %TDA_UN% /p %TDA_PW% /o %ALBUM_DUMP_FILE% /level photo
	echo [Write to Summary Album]
		%BinPath%\PicasaHelper buildSummaryAlbum /a %TWSA_UN% /p %TWSA_PW% /t %TWSA_T% /s %ALBUM_DUMP_FILE%
	echo [Write to Calendar]
		%BinPath%\CalendarHelper buildCalendar /a %TWC_UN% /p %TWC_PW% /t %TWC_T% /s %ALBUM_DUMP_FILE% /detectOriginal replaceOld /summaryAlbumUrl %TWC_SALU%
	
	popd

goto :eof

:ShowHelp
	
	echo Combination of
	echo	1.Read Picasa album data
	echo	2.Write to Picasa summary Album
	echo	3.Write to Google Calendar
	echo format: %~n0
	echo 	[ToDetectAlbum]       UserName PW
	echo 	[ToWriteSummaryAlbum] UserName PW Title
	echo 	[ToWriteCalendar]     UserName PW Title SummaryAlbumLinkUrl
	
goto :eof